import sys
import random

def f(x,y,x1):
    n=len(x)
    xAvg = sum(x)/n
    yAvg = sum(y)/n
    ly = sum(map(lambda ax,ay:ax*ay,x,y))-n*xAvg*yAvg
    lx = sum(map(lambda ax:ax*ax,x))-n*xAvg*xAvg
    k = ly/lx
    b = yAvg - k*xAvg
    dist = sum(map(lambda ax,ay:(k*ax+b-ay)**2,x,y))
    y1 = k*x1 + b
    return k,b,dist,y1

a=[[[1,2,3,4,5],[5,6,7,8,10],6],
   [[2014,2015,2016,2017,2018],[5,6,7,8,10],2019],
   [[60,62,64,65,66,67,68,70,72,74],[63.6,65.2,66,65.5,66.9,67.1,67.4,68.3,70.1,70],78]
  ]

for i  in range(3):
    fin = open('{}.in'.format(i+1),'w')
    fout = open('{}.out'.format(i+1),'w')
    print(*a[i][0],file=fin)
    print(*a[i][1],file=fin)
    print(a[i][2],file=fin)
    result = f(*a[i])
    print('{:.3f} {:.3f} {:.3f} {:.3f}'.format(*result),file=fout)
    fin.close()
    fout.close()

